<?php
    require_once('../lib/JSSDK.php');
    $jssdk = new JSSDK("wx4aed25d0aeefc592","6368d8bf66542dd5d0d3e9cfbd50be37");
    $signPackage = $jssdk->getSignPackage();
?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>微信</title>
    <!-- <link href="/css/bootstrap.min.css" rel="stylesheet"> -->
    <link href="/css/common.css" rel="stylesheet">
    <link href="/css/chatstyle.css" rel="stylesheet">
    <!-- Include these three JS files: -->
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script type="text/javascript" src="/js/swfobject.js"></script>
    <script type="text/javascript" src="/js/web_socket.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>

    <script type="text/javascript">
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '<?php echo $signPackage["appId"];?>',
            timestamp: <?php echo $signPackage["timestamp"];?>,
            nonceStr: '<?php echo $signPackage["nonceStr"];?>',
            signature: '<?php echo $signPackage["signature"];?>',
            jsApiList: [
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'onMenuShareQZone',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',
            'translateVoice',
            'startRecord',
            'stopRecord',
            'onVoiceRecordEnd',
            'playVoice',
            'onVoicePlayEnd',
            'pauseVoice',
            'stopVoice',
            'uploadVoice',
            'downloadVoice',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'getNetworkType',
            'openLocation',
            'getLocation',
            'hideOptionMenu',
            'showOptionMenu',
            'closeWindow',
            'scanQRCode',
            'chooseWXPay',
            'openProductSpecificView',
            'addCard',
            'chooseCard',
            'openCard'
            ] // JS接口列表，所有JS接口列表见附录2
        });

    </script>
</head>
<body>
	<input type="text" id="localId">
	<button onclick="play($('#localId').val());">播放</button>
	<script type="text/javascript">
        function writeObj(obj){ 
         var description = ""; 
         for(var i in obj){ 
         var property=obj[i]; 
         description+=i+" = "+property+"\n"; 
         } 
         alert(description); 
        } 
		
        function play(localId){
        	alert(localId);
            wx.downloadVoice({
                serverId: localId, // 需要下载的音频的服务器端ID，由uploadVoice接口获得
                isShowProgressTips: 1, // 默认为1，显示进度提示
                success: function (res) {
                    writeObj(res);
                    wx.playVoice({
                        localId: res.localId
                    });
                }
            });
        }

	</script>	
</body>
</html>